﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace BLL
{
    public class BTaxiADInfo
    {
        private readonly DAL.DTaxiADInfo _dal = new DAL.DTaxiADInfo();

        #region  Method

        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return _dal.GetMaxId();
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int taxiId, int adId)
        {
            return _dal.Exists(taxiId, adId);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.TaxiAdInfo model)
        {
            return _dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.TaxiAdInfo model)
        {
            return _dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {

            return _dal.Delete(id);
        }

        public bool Delete(int taxiId, int adid)
        {
            return _dal.Delete(taxiId, adid);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string idlist)
        {
            return _dal.DeleteList(idlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.TaxiAdInfo GetModel(int id)
        {

            return _dal.GetModel(id);
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return _dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.TaxiAdInfo> GetModelList(string strWhere)
        {
            DataSet ds = _dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.TaxiAdInfo> DataTableToList(DataTable dt)
        {
            List<Model.TaxiAdInfo> modelList = new List<Model.TaxiAdInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.TaxiAdInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.TaxiAdInfo();
                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["TaxiId"] != null && dt.Rows[n]["TaxiId"].ToString() != "")
                    {
                        model.TaxiId = int.Parse(dt.Rows[n]["TaxiId"].ToString());
                    }
                    if (dt.Rows[n]["ADID"] != null && dt.Rows[n]["ADID"].ToString() != "")
                    {
                        model.Adid = int.Parse(dt.Rows[n]["ADID"].ToString());
                    }
                    if (dt.Rows[n]["ADContent"] != null && dt.Rows[n]["ADContent"].ToString() != "")
                    {
                        model.ADContent = dt.Rows[n]["ADContent"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return _dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return _dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}
